<?php 
namespace Common\Model;
use Think\Model;
class TypeModel extends Model{
	protected $tableName = 'protype';
		
	function showOption($currentTypeId=''){
		$TypeOneArr = $this->where('pid= 0')
						->select();
		$optionStr = '';
		foreach($TypeOneArr as $v){
			$optionStr.="<optgroup label='{$v['name']}'>";
			$TypeTwoArr = $this->where("pid = {$v['id']}")
								->select();
								foreach ($TypeTwoArr as $tv) {
								if($tv['id']==$currentTypeId){
					$optionStr.="<option selected='selected' value='{$v['id']}|{$tv['id']}'>{$tv['name']}</option>";
				}else{
					$optionStr.="<option value='{$v['id']}|{$tv['id']}'>{$tv['name']}</option>";
				}
			

		}
		$optionStr.="</optgroup>";
	}
	return $optionStr;
}
}